package com.technology.education.dslitem

import com.angcyo.dsladapter.DslAdapterItem
import com.angcyo.dsladapter.DslViewHolder
import com.technology.education.dslitem.style.BaseStyle
import com.technology.education.ext.getColor

/**
 *@author:create by BZY
 *Date: 2020/8/11 10
 * 样式基本类
 */
open class BaseStyleAdapterItem(var style: BaseStyle = BaseStyle()) : DslAdapterItem() {
    override fun onItemBind(
        itemHolder: DslViewHolder,
        itemPosition: Int,
        adapterItem: DslAdapterItem,
        payload:List<Any>
    ) {
        super.onItemBind(itemHolder, itemPosition, adapterItem,payload)

        style.let {
            if (it.itemHeight > 0) {
                itemHeight = it.itemHeight
            }
            itemSpanCount = it.itemSpan
            itemTopInsert = it.topLine
            itemBottomInsert = it.lineHeight
            itemDecorationColor = getColor(it.lineColor)
            itemLeftOffset = it.leftOffset
            itemRightOffset = it.rightOffset
            itemTopOffset = it.topOffset
            itemBottomOffset = it.bottomOffset
        }
    }
}